package io.renren.modules.weldworkplan.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.weldworkplan.entity.WeldworkplanEntity;
import io.renren.modules.weldworkplan.service.WeldworkplanService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-08-04 19:08:14
 */
@RestController
@RequestMapping("weldworkplan/weldworkplan")
public class WeldworkplanController {
    @Autowired
    private WeldworkplanService weldworkplanService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("weldworkplan:weldworkplan:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = weldworkplanService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{wmpNo}")
    @RequiresPermissions("weldworkplan:weldworkplan:info")
    public R info(@PathVariable("wmpNo") Integer wmpNo){
		WeldworkplanEntity weldworkplan = weldworkplanService.getById(wmpNo);

        return R.ok().put("weldworkplan", weldworkplan);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("weldworkplan:weldworkplan:save")
    public R save(@RequestBody WeldworkplanEntity weldworkplan){
		weldworkplanService.save(weldworkplan);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("weldworkplan:weldworkplan:update")
    public R update(@RequestBody WeldworkplanEntity weldworkplan){
		weldworkplanService.updateById(weldworkplan);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("weldworkplan:weldworkplan:delete")
    public R delete(@RequestBody Integer[] wmpNos){
		weldworkplanService.removeByIds(Arrays.asList(wmpNos));

        return R.ok();
    }

}
